home *** CD-ROM | disk | FTP | other *** search
/ Champak 103 / Vol 103.iso / games / shark_at.swf / scripts / DefineSprite_82 / frame_1 / DoAction.as
Text File  |  2010-03-13  |  2KB  |  60 lines

  1. x = _X + _parent._x;
  2. y = _Y + _parent._y;
  3. width = _width / 2;
  4. if(x + width < -100 || 650 < x - width)
  5. {
  6.    gotoAndPlay(3);
  7. }
  8. if(x < _root.mascot._x)
  9. {
  10.    slope = y - (x - _root.mascot._x) * _height / _width;
  11. }
  12. else
  13. {
  14.    slope = y - (_root.mascot._x - x) * _height / _width;
  15. }
  16. if(x - width < _root.mascot._x && _root.mascot._x < x + width && (slope - _root.mascot.jumpspeed < _root.mascot._y + 40 && _root.mascot._y + 40 < slope + (slope + _height / 2 - slope)) && _root.mascot.jumping != true)
  17. {
  18.    _root.mascot.air = false;
  19.    _root.mascot._y = slope - 40;
  20.    if(mascot != true)
  21.    {
  22.       _root.mascot.platform_contact = _root.mascot.platform_contact + 1;
  23.       mascot = true;
  24.    }
  25.    if(_name == "mainland" && x - width / 2 < _root.mascot._x)
  26.    {
  27.       _root.gotoAndStop("win");
  28.    }
  29. }
  30. else if(mascot == true)
  31. {
  32.    if(_root.mascot.platform_contact == 1)
  33.    {
  34.       _root.mascot.air = true;
  35.    }
  36.    _root.mascot.platform_contact--;
  37.    mascot = false;
  38. }
  39. i = 1;
  40. while(_root.enemies >= i)
  41. {
  42.    enemy_x = _parent["enemy" + i]._x;
  43.    if(_X < enemy_x)
  44.    {
  45.       slope = _Y - (_X - enemy_x) * _height / _width;
  46.    }
  47.    else
  48.    {
  49.       slope = _Y - (enemy_x - _X) * _height / _width;
  50.    }
  51.    if(_X - width < enemy_x && enemy_x < _X + width)
  52.    {
  53.       _parent["enemy" + i].start_x = _X;
  54.       _parent["enemy" + i].dest_left = _X - width;
  55.       _parent["enemy" + i].dest_right = _X + width;
  56.       _parent["enemy" + i]._y = slope - 30;
  57.    }
  58.    i++;
  59. }
  60.